import pandas as pd
from fuzzywuzzy import fuzz


df = pd.read_excel(rf'D:\Desktop\mynewlearn\新建 Microsoft Excel 工作表 (2).xlsx')

z = []
p = []
sorearr=[]


print(z)
for i in df.index:
    sorei = 0
    mybe = ''
    for j in df.index:
        if j != i:
            sorej =fuzz.ratio(df['项目'].at[i], df['项目'].at[j])

            if sorej > sorei:
                mybe = df['项目'].at[j]
                sorei = sorej

    z.append(df["项目"].at[i])
    p.append(mybe)
    sorearr.append(sorei)


mydata = dict()
mydata['z'] = z
mydata['p'] = p
mydata['sore'] = sorearr
df1 = pd.DataFrame(mydata)
df1.to_excel(rf'D:\Desktop\mynewlearn\my2.xlsx')
